<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>欢乐谷</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <link rel="stylesheet" href="/new/layui/css/layui.css">
    <link rel="stylesheet" href="/new/css/entertain/x-admin.css" media="all">
    <script type="text/javascript" src="/new/js/entertain/xadmin.js"></script>
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label disabled">id</label>
        <div class="layui-input-inline">
            <input type="text" name="facilityId" disabled="disabled" required  lay-verify="required" th:value="${onefacility.facilityId}" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">不可修改</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">设施名</label>
        <div class="layui-input-inline">
            <input type="text" name="facilityName" required lay-verify="required" th:value="${onefacility.facilityName}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">设施介绍</label>
        <div class="layui-input-block">
            <textarea name="facilityContent"  class="layui-textarea" th:text="${onefacility.facilityContent}"></textarea>
        </div>
    </div>
    <input type="hidden" name="facilityStatus" th:value="${onefacility.facilityStatus}">
    <div class="layui-form-item">
        <label class="layui-form-label">设施点赞数</label>
        <div class="layui-input-inline">
            <input type="text" name="facilityGreat" required lay-verify="required" th:value="${onefacility.facilityGreat}" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">主题</label>
        <div class="layui-input-block">
            <ul th:each="x:${entertainment}" style="float: left">
                <li>
                    <input type="radio" name="entertainmentList"
                           th:checked="${onefacility.entertainmentList.size() > 0 && x.entertainmentName == onefacility.entertainmentList[0].entertainmentName}"
                           th:title="${x.entertainmentName}" th:value="${x.entertainmentId}">
                </li>
            </ul>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="/new/layui/layui.js" charset="utf-8">
</script>
<script src="/new/js/entertain/x-layui.js" charset="utf-8">
</script>
<script>
        //保存按钮
        /*form.on('submit(add)',function (data) {
            console.log(data);

            $.ajax({
                url:"/staffInfoDetail/updateStaff",
                /!*当async属性的值为false时是同步的
                  Ajax请求将整个浏览器锁死，只有ajax请求返回结果后，才执行ajax后面的alert语句。
                  当async属性的值为true时是异步的
                  即不会等待ajax请求返回的结果，会直接执行ajax后面的alert语句。*!/
                async:false,
                type:"POST",
                dataType:"json",
                data:data.field,
                success:function (data) {
                    //提示信息

                    //放入了map中，调用info
                    if (data.info=="修改成功"){
                        layer.alert(data.info);
                        //获得frame索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                        //刷新
                        parent.window.location.replace("/staffInfoDetail/list")}}})
            return false;});});*/
    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){
            var entertainmentList = [];
            var entertainment = {};
            entertainment.entertainmentId = data.field.entertainmentList;
            entertainmentList.push(entertainment);
            data.field.entertainmentList = entertainmentList;
            console.log(JSON.stringify(data.field));
            $.ajax({
                url : "/manager/modifyf",
                type : "post",
                contentType: "application/json",
                data : JSON.stringify(data.field),
                success : function (data) {
                    if (data.status == 200) {
                        layer.alert(data.message,function () {
                            //关闭弹出窗，刷新list页面
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload();
                            parent.layer.close(index);
                        });
                    } else {
                        layer.alert(data.message);
                    }
                },
                error : function (data) {
                    layer.alert(data.responseText);
                }
            });
            return false;
        });
    });

</script>
</body>
</html>